<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>for-of demo</title>
    <script src="../helpers/bing.js"></script>
  </head>
  <body>
    <script>
      const asyncFunction = async (item) => {
        await new Promise((resolve) => setTimeout(resolve, 1000));
        console.log(item);
      };

      const items = [1, 2, 3];

      const run = async () => {
        for (const item of items) {
          await asyncFunction(item);
        }

        console.log("Completed"); // 这个输出会在所有异步操作完成之后输出
      };

      run();
    </script>
  </body>
</html>
